package com.yuanian.springbootProject.service.imp;

import com.yuanian.springbootProject.dao.TRoleMapper;
import com.yuanian.springbootProject.dao.TUserRoleMapper;
import com.yuanian.springbootProject.entity.TRole;
import com.yuanian.springbootProject.service.IRoleService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class RoleService implements IRoleService {

    @Resource
    private TRoleMapper roleMapper;

    @Resource
    private TUserRoleMapper userRoleMapper;

    @Override
    public int deleteByPrimaryKey(String roleId) {
        return roleMapper.deleteByPrimaryKey(roleId);
    }

    @Override
    public int deleteRoleAndRelationByPrimaryKey(String roleId) {
        return userRoleMapper.deleteByRoleId(roleId) + roleMapper.deleteByPrimaryKey(roleId);
    }

    @Override
    public int insert(TRole record) {
        return roleMapper.insert(record);
    }

    @Override
    public int insertSelective(TRole record) {
        return roleMapper.insertSelective(record);
    }

    @Override
    public TRole selectByPrimaryKey(String roleId) {
        return roleMapper.selectByPrimaryKey(roleId);
    }

    @Override
    public int updateByPrimaryKeySelective(TRole record) {
        return roleMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(TRole record) {
        return roleMapper.updateByPrimaryKey(record);
    }

    @Override
    public List<TRole> selectAll() {
        return roleMapper.selectAll();
    }
}
